﻿<?php
    session_start();
    if(isset($_POST['yhm']) && isset($_POST['sjh']) && isset($_GET['m']) && isset($_POST['pw'])){
        echo '暂时不允许注册';
        exit;
        $yhm = htmlspecialchars($_POST['yhm']);
        if(strlen($yhm) > 20)exit('用户名过长');
        if(strlen($yhm) <= 0)exit('需要用户名');
        $sjh = htmlspecialchars($_POST['sjh']);
        if(strlen($sjh) <= 0)exit('需要手机号码');
        if(strlen($sjh) != 11 || substr($sjh,0,1) != '1')exit('手机号码不正确');
        $pw = $_POST['pw'];
        if(preg_match("/[^ 0-9,a-z,A-Z]/",$pw))exit('密码只能是数字和字母组成');
        if(strlen($pw) > 16)exit('密码太长');
        if(strlen($pw) <= 0)exit('需要输入密码');
        if(strlen($pw) < 6)exit('密码太短');
        require ("../quanju.php");
        $result = $conn->query("SELECT * FROM hg002 WHERE yhm='{$yhm}'");
        if($result){
            if($row = mysqli_fetch_array($result)){
                $conn->close();
                exit('用户名已存在');
            }
        }
        $result = $conn->query("SELECT * FROM hg002 WHERE sjh='{$sjh}'");
        if($result){
            if($row = mysqli_fetch_array($result)){
                $conn->close();
                exit('这个手机号码已被注册');
            }
        }
        $result = $conn->query("INSERT INTO `hg002` (`sjh`, `yhm`, `data`, `lx`, `pw`, `wd`, `wdsj`, `imglj`, `bttb`, `jkm`, `jkmsj`, `js`, `reg_date`, `zt`, `loginsj`, `ylwz`, `bwlzdfh`, `sid`, `IP`, `tybztdx`, `tybazck`, `tybtouchpeek`, `Xdjgjc`, `Xdjjr`, `ymms`)
VALUES ('{$sjh}', '{$yhm}', '未激活用户', 'wjh', '{$pw}', NULL, NULL, NULL, NULL, NULL, NULL, NULL, now(), '1', NULL, NULL, '0', NULL, NULL, '20', '0', '0', NULL, '0', '0');");
        $conn->close();        
        if($result){
            $_SESSION['xiaoxi'] = '注册成功';
            exit('1');
        }
        else exit('注册失败');
        
    }
?>
<!DOCTYPE html>
<html>
    <head>
        <title>002注册页面</title>
         <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no"/>
        <meta name="apple-mobile-web-app-capable" content="yes"/>
        <meta name="apple-touch-fullscreen" content="yes"/>
        <meta http-equiv="Access-Control-Allow-Origin" content="*"/>
        <link href="css/register.css" type="text/css" rel="stylesheet"/>

        <link rel="stylesheet" href="css/bootstrap.css" />


        <script type="text/javascript" src="js/register.js"></script>
        <script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?b136fdcc890043f71942e245f3d174ea";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

    </head>
    <body>

        <div  class="container">



                    
                <div class="login">
                    <form method="post" action="register.php?tz=1" onSubmit="return TryReg();">
                        <div class="login-bar">
                            <div style="text-align: center;"><h2 style="color: white;">注册页面</h2></div>

                            <ul>



                                <li>
<!--                                    <img src="images/login_user.png" />-->
                                    <input id="yhm" type="text" class="text" name="yhm" placeholder="用户名" /></li>
                                <li>
<!--                                    <img src="images/login_user.png" />-->
                                    <input id="sjh" type="text" class="text" name="sjh" placeholder="手机号" /></li>
                                <li>
<!--                                    <img src="images/login_pwd.png" />-->
                                    <input id="pw" type="password" class="psd" name="pw" placeholder="密码"  /></li>
                                <li>
<!--                                    <img src="images/login_pwd.png" />-->
                                    <input id="pw2" type="password" class="psd" name="pw2" placeholder="确认密码" />
                                </li>

                            </ul><div style=" text-align: center;"><i></i></div>
                        </div>
                        <div class="reg-btn">
                            <button class="submit" type="submit">注册</button>
                        </div>

                    </form>
        </div>
                </div>


            </div>






    </body>
</html>